﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

using Xc.DataAccess.Core.Extensions;

namespace Xc.Logics.HyperTerminalCore.Udp.Models
{
    public class HexConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is byte[] contents)
            {
                return contents.ToHex();
            }
            else
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string contents)
            {
                return contents.ToHex();
            }
            else
            {
                return null;
            }
        }
    }
}
